<#include "header.htm"/>

<div id="tabs">
			<ul>
				<li><a href="${JForumContext.encodeURL("/admBase/login")}"><span>${I18n.getMessage("Admin.general")}</span></a></li>
	
			
				<li><a href="${contextPath}/adminGroups/list${extension}"><span>${I18n.getMessage("Admin.groups")}</span></a></li>
				<li><a href="${contextPath}/adminUsers/list${extension}"><span>${I18n.getMessage("Admin.users")}</span></a></li>
				<li><a href="${contextPath}/adminCategories/list${extension}"><span>${I18n.getMessage("Admin.categories")}</span></a></li>				
				<li id="activetab"><a href="${contextPath}/adminForums/list${extension}"><span>${I18n.getMessage("Admin.forums")}</span></a></li>
				<li><a href="${contextPath}/adminModeration/list${extension}"><span>${I18n.getMessage("Admin.approving")}</span></a></li>
			
				<li><a href="${contextPath}/adminRankings/list${extension}"><span>${I18n.getMessage("Admin.rankings")}</span></a></li>				
				<li><a href="${contextPath}/adminBanning/list${extension}"><span>${I18n.getMessage("Admin.banning")}</span></a></li>
				
				
				
				
				<li><a href="${contextPath}/adminConfig/list${extension}"><span>${I18n.getMessage("Admin.configurations")}</span></a></li>
			
				<li><a href="${contextPath}/adminSmilies/list${extension}"><span>${I18n.getMessage("Admin.smilies")}</span></a></li>
			
				<li><a href="${contextPath}/adminSearchStats/list${extension}"><span>${I18n.getMessage("Admin.search")}</span></a></li>
			
				<li><a href="${contextPath}/adminAttachments/configurations${extension}"><span>${I18n.getMessage("Admin.attachments")}</span></a></li>
			
				<li><a href="${contextPath}/adminCache/list${extension}"><span>${I18n.getMessage("Admin.cache")}</span></a></li>
			
			</ul>
</div>




<div id="acp">
		<div class="panel">
			<span class="corners-top"><span></span></span>
				<div id="content">
				    <div id="main">
				    
<#setting number_format = "#"/>
<#import "macros/group_macros.ftl" as lib>
<#assign edit = forum?exists/>


<form action="${contextPath}/jforum${extension}" method="post" name="form" id="form" accept-charset="${encoding}" onSubmit="return checkInput();" enctype="multipart/form-data">
<input type="hidden" name="action" value="${action}" />
<input type="hidden" name="module" value="${moduleName}" />

<#if !edit>
	<#list groups as g>
		<input type="hidden" name="groups" value="${g.id}">
	</#list>
</#if>

<script language="javascript">
function checkGroups() 
{
	<#if !edit>
		if (document.form.groups.selectedIndex == -1) {
			alert("${I18n.getMessage("PermissionControl.atLeastOne")}");
			return false;
		}
	</#if>

	return true;
}

function checkCategory()
{
	if (document.form.categories_id.selectedIndex < 0) {
		alert("${I18n.getMessage("Forums.Form.ChooseCategory")}");
		return false;
	}

	return true;
}

function checkInput()
{
	return checkGroups() && checkCategory();
	//return checkGroups() && checkCategory() && validateMailIntegration();
}

function showMailIntegration(checked)
{
	document.getElementById("mail_integration_tr").style.display = checked ? "" : "none";
}

function validateMailIntegration()
{
	var f = document.form;

	if (f.mail_integration.checked) {
		var baseMessage = "${I18n.getMessage("Forums.Form.FieldEmpty")}: ";
		
		if (f.forum_email.value == "") {
			alert(baseMessage + "${I18n.getMessage("Forums.Form.ForumEmail")}");
			f.forum_email.focus();
			return false;
		}

		if (f.pop_host.value == "") {
			alert(baseMessage + "${I18n.getMessage("Forums.Form.PopHost")}");
			f.pop_host.focus();
			return false;
		}

		if (f.pop_host.value == "") {
			alert(baseMessage + "${I18n.getMessage("Forums.Form.PopHost")}");
			f.pop_host.focus();
			return false;
		}

		if (f.pop_port.value == "") {
			alert(baseMessage + "${I18n.getMessage("Forums.Form.PopPort")}");
			f.pop_port.focus();
			return false;
		}

		if (f.pop_username.value == "") {
			alert(baseMessage + "${I18n.getMessage("Forums.Form.PopUsername")}");
			f.pop_username.focus();
			return false;
		}

		if (f.pop_password.value == "") {
			alert(baseMessage + "${I18n.getMessage("Forums.Form.PopPassword")}");
			f.pop_password.focus();
			return false;
		}
	}
}

function limitTextArea(field, limit)
{
	if (field.value.length > limit) {
		field.value = field.value.substring(0, limit);
	}
}
</script>

<#if edit>
<input type="hidden" name="forum_id" value="${forum.id}" />
</#if>


<fieldset>
		<legend>${I18n.getMessage("Forums.Form.Title")}</legend>
	<dl>
		<dt><label for="forum_name">${I18n.getMessage("Forums.Form.ForumName")}:</label></dt>
		<dd><input type="text" style="WIDTH: 200px" maxlength="200" size="25" name="forum_name" id="forum_name" value="<#if forum?exists>${forum.name}</#if>" /></dd>
	</dl>
	
	<dl>
		<dt><label for="moderate">${I18n.getMessage("Forums.Form.Moderate")}:</label></dt>
		<dd>
			<label><input type="radio" class="radio" name="moderate" value="0"<#if forum?exists><#if !forum.isModerated()>checked</#if><#else>checked</#if>/> ${I18n.getMessage("User.no")}</label>
		    <label><input type="radio" class="radio" name="moderate" value="1" id="moderate"<#if forum?exists && forum.isModerated()>checked</#if>/> ${I18n.getMessage("User.yes")}</label>
		</dd>
	</dl>
	
		<dl>
			<dt><label for="categories_id">${I18n.getMessage("Forums.Form.Category")}:</label></dt>
			<dd>
			    <select name="categories_id" id="categories_id">
			    	<#list categories as c><option value="${c.id}" <#if forum?exists><#if forum.categoryId == c.id>selected</#if></#if>>${c.name}</option></#list>
			    </select>
            </dd>
		</dl>
	

	<dl>
		<dt><label for="description">${I18n.getMessage("Forums.Form.Description")}:</label></dt>
		<dd><textarea name="description" name="description" cols="40" rows="10" style="width: 100%" onKeyDown="limitTextArea(this, 255);" onKeyUp="limitTextArea(this, 255);"><#if forum?exists>${forum.description?default("")}</#if></textarea></dd>
		
	</dl>

	</fieldset>
	
	<#if !edit>
	
	<fieldset>
		<legend>${I18n.getMessage("Forums.Form.Permissions")}</legend>
	<dl>
		<dt><label for="groupsAccess">${I18n.getMessage("Forums.Form.RestrictAccessToGroup")}:</label></dt>
		<dd><@lib.selectFieldGroups "groupsAccess", groups, 0, true, selectedList/></dd>
	</dl>

	<dl>
		<dt><label for="groupsAnonymous">${I18n.getMessage("Forums.Form.RestrictAnonymousPostToGroup")}:</label></dt>
		<dd><@lib.selectFieldGroups "groupsAnonymous", groups, 0, true, selectedList/></dd>
	</dl>

	<dl>
		<dt><label for="groupsReadOnly">${I18n.getMessage("Forums.Form.MarkAsReadOnlyToGroup")}:</label></dt>
		<dd><@lib.selectFieldGroups "groupsReadOnly", groups, 0, true, selectedList/></dd>
	</dl>

	<dl>
		<dt><label for="groupsHtml">${I18n.getMessage("Forums.Form.RestrictHtmlToGroup")}:</label></dt>
		<dd><@lib.selectFieldGroups "groupsHtml", groups, 0, true, selectedList/></dd>
	</dl>

	</fieldset>
	</#if>


<fieldset class="submit-buttons">
		<input class="button1" type="submit" value="${I18n.getMessage("Forums.Form.ClickToUpdate")}" name="submit">
</fieldset>


</form>

<#if false && mailIntegration?exists>
	<script type="text/javascript">showMailIntegration(true);</script>
</#if>


</div>
</div>
	<span class="corners-bottom"><span></span></span>
</div>
</div>

<#include "bottom.htm"/>
